package com.jx.gocomtask.webservice.entity;

import java.io.Serializable;
import javax.persistence.*;

import com.fasterxml.jackson.annotation.JsonManagedReference;
import com.jx.gocomtask.webservice.DTO.TaskScope;
import com.jx.gocomtask.webservice.DTO.TaskStatus;
import com.jx.gocomtask.webservice.DTO.TodoStatus;
import com.jx.gocomtask.webservice.entity.base.ExtTaskTodoBase;
import com.jx.gocomtask.webservice.entity.listener.ExtTaskTodoListener;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;


/**
 * The persistent class for the ext_task_todo database table.
 * 
 */
@Entity
@Table(name="ext_task_todo")
@NamedQuery(name="ExtTaskTodo.findAll", query="SELECT e FROM ExtTaskTodo e")
@EntityListeners(ExtTaskTodoListener.class)
public class ExtTaskTodo extends ExtTaskTodoBase implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	private Long id;

	private String content;

	@Column(name="update_time", insertable = false, updatable = false)
	private Date updateTime;
	
	@Column(name="create_time", insertable = false, updatable = false)
	private Date createTime;

	@Column(name="from_device")
	private String fromDevice;

	@Column(name="from_user_name")
	private String fromUserName;
	
	@Column(name="from_user")
	private String fromUser;

	@Column(name="gocom_group")
	private String gocomGroup;

	@Column(name="message_type")
	private String messageType;
	
	@Column(name="msg_id")
	private int msgId=0;
	
	@Column(name="message_id")
	private long messageId=0;
	
	@Enumerated(EnumType.ORDINAL)
	private TaskStatus status;

	@Column(name="todo_status")
	@Enumerated(EnumType.ORDINAL)
	private TodoStatus todoStatus;

	@Enumerated(EnumType.ORDINAL)
	private TaskScope scope;
	
	@Column(name = "context_flag")
	private Integer contextFlag = 0;

	private Integer source = 0;
	//bi-directional many-to-one association to ExtTaskTodoUser
	@OneToMany(mappedBy="extTaskTodo"  ,cascade = {CascadeType.ALL}, fetch = FetchType.LAZY)
	@JsonManagedReference
	private List<ExtTaskTodoUser> extTaskTodoUsers=new ArrayList<>(); 

	public ExtTaskTodo() {
	}

	public Long getId() {
		return this.id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getContent() {
		return this.content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public Date getCreateTime() {
		return this.createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	public String getFromDevice() {
		return this.fromDevice;
	}

	public void setFromDevice(String fromDevice) {
		this.fromDevice = fromDevice;
	}

	public String getFromUserName() {
		return this.fromUserName;
	}

	public void setFromUserName(String fromUserName) {
		this.fromUserName = fromUserName;
	}

	public String getGocomGroup() {
		return this.gocomGroup;
	}

	public void setGocomGroup(String gocomGroup) {
		this.gocomGroup = gocomGroup;
	}

	public String getMessageType() {
		return this.messageType;
	}

	public void setMessageType(String messageType) {
		this.messageType = messageType;
	}

	public TaskStatus getStatus() {
		return this.status;
	}

	public void setStatus(TaskStatus stats) {
		this.status = stats;
	}

	public TodoStatus getTodoStatus() {
		return this.todoStatus;
	}

	public void setTodoStatus(TodoStatus todoStatus) {
		this.todoStatus = todoStatus;
	}

	public Date getUpdateTime() {
		return this.updateTime;
	}

	public void setUpdateTime(Date updateTime) {
		this.updateTime = updateTime;
	}

	public List<ExtTaskTodoUser> getExtTaskTodoUsers() {
		return this.extTaskTodoUsers;
	}

	public void setExtTaskTodoUsers(List<ExtTaskTodoUser> extTaskTodoUsers) {
		this.extTaskTodoUsers = extTaskTodoUsers;
	}

	public ExtTaskTodoUser addExtTaskTodoUser(ExtTaskTodoUser extTaskTodoUser) {
		getExtTaskTodoUsers().add(extTaskTodoUser);
		extTaskTodoUser.setExtTaskTodo(this);

		return extTaskTodoUser;
	}

	public ExtTaskTodoUser removeExtTaskTodoUser(ExtTaskTodoUser extTaskTodoUser) {
		getExtTaskTodoUsers().remove(extTaskTodoUser);
		extTaskTodoUser.setExtTaskTodo(null);

		return extTaskTodoUser;
	}

	public String getFromUser() {
		return fromUser;
	}

	public void setFromUser(String fromUser) {
		this.fromUser = fromUser;
	}

	public TaskScope getScope() {
		return scope;
	}

	public void setScope(TaskScope scope) {
		this.scope = scope;
	}

	public Integer getContextFlag() {
		return contextFlag;
	}

	public void setContextFlag(Integer contextFlag) {
		this.contextFlag = contextFlag;
	}

	public int getMsgId() {
		return msgId;
	}

	public void setMsgId(int msgId) {
		this.msgId = msgId;
	}

	public Integer getSource() {
		return source;
	}

	public void setSource(Integer source) {
		this.source = source;
	}

	public long getMessageId() {
		return messageId;
	}

	public void setMessageId(long messageId) {
		this.messageId = messageId;
	}


}